package gjtx2;

public class Comparison {
    public static void main(String[] args) {
        StringBuffer sb=new StringBuffer();
        StringBuilder sd=new StringBuilder();
        String a="A";
        long b=System.nanoTime();
        for (int i=1;i<=100000;i++){
            sd.append(a);
        }
        long bsd=System.nanoTime()-b;
        long b1=System.nanoTime();
        for (int i=1;i<=100000;i++){
            sb.append(a);
        }
        long bsb=System.nanoTime()-b1;
        if (bsd>bsb){
            System.out.println("StringBuilder更快！");
        }else if (bsd<bsb){
            System.out.println("StringBuffer更快!");
        }else {
            System.out.println("一样！");
        }
    }
}
